#include <bits/stdc++.h>
using namespace std;
class Tnode{
public:
    int data;
    Tnode* pLchild;
    Tnode* pRchild;
    Tnode(int d,Tnode* l = nullptr,Tnode* r = nullptr)
    {
        data = d;
        pLchild = l;
        pRchild = r;
    }
};
void Find_Path(Tnode* r,int v,vector<int>& path,int current_sum)
{
    current_sum += r->data;
    path.push_back(r->data);
    bool isLeaf = r->pLchild == nullptr && r->pRchild == nullptr;
    if(current_sum == v && isLeaf)
    {
        for(auto i:path)
            cout<<i<<" ";
        cout<<"\n";
    }
    if(r->pLchild!= nullptr)
        Find_Path(r->pLchild,v,path,current_sum);
    if(r->pRchild != nullptr)
        Find_Path(r->pRchild,v,path,current_sum);
    path.pop_back();
}
void Find_Path(Tnode* r,int v)
{
    if(r == nullptr)
        return;
    vector<int> path;
    int current_sum = 0;
    Find_Path(r,v,path,current_sum);
}
int main() {
    Tnode* a = new Tnode(10);
    Tnode* b = new Tnode(5);
    Tnode* c = new Tnode(12);
    Tnode* d = new Tnode(4);
    Tnode* e = new Tnode(7);
    vector<int> result;
    a->pLchild = b;
    a->pRchild = c;
    b->pLchild = d;
    b->pRchild = e;
    int current_value = 0;
    vector<int> s;
    Find_Path(a,22,s,current_value);
    delete a,b,c,d,e;
    return 0;
}